﻿using Titan.Core;
using System.Configuration;

namespace Titan.FIS.LmsDataSync
{
    /// <summary>
    /// 配置文件参数
    /// </summary>
    internal class CfgHelper
    {
        /// <summary>
        /// 数据库类型
        /// </summary>
        public static DataBaseType DatabaseType
        {
            get
            {
                var dbType = DataBaseType.ORACLE;
                try
                {
                    dbType = (DataBaseType)System.Enum.Parse(typeof(DataBaseType), ConfigurationManager.AppSettings["DBType"], true); 
                }
                catch
                {
                    // ignored
                }
                return dbType;
            }
        }

        /// <summary>
        /// 数据库连接串
        /// </summary>
        public static string DBConnStr
        {
            get { return ConfigurationManager.AppSettings["DBConnStr"]; }
        }

        /// <summary>
        /// 数据库执行时长，单位秒
        /// </summary>
        public static int DBExecTimeout
        {
            get
            {
                var dbExecTimeout = 30;
                int.TryParse(ConfigurationManager.AppSettings["DBExecTimeout"], out dbExecTimeout);
                return dbExecTimeout;
            }
        }
    }
}
